summaryrefslogtreecommitdiff
path: root/kernel/usrbin/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/usrbin/Makefile')
-rw-r--r--kernel/usrbin/Makefile27
1 files changed, 21 insertions, 6 deletions
diff --git a/kernel/usrbin/Makefile b/kernel/usrbin/Makefile
index dfd1b84..dd42909 100644
--- a/kernel/usrbin/Makefile
+++ b/kernel/usrbin/Makefile
@@ -1,17 +1,32 @@
-TARGET = usrbin.o
+TARGET = usrbin_blob.o
-ASM = nasm
+SRCS = $(wildcard *.c)
+ASMS = $(wildcard *.s)
+OBJS = $(SRCS:.c=.o) $(ASMS:.s=.o)
+
+CFLAGS = -m32 -I../../include -ffreestanding -nostdinc -nostdlib -fno-stack-protector -fno-pie
+LDFLAGS = -m elf_i386 -T link.ld
+ASMFLAGS = -f elf32
+
+CC = gcc $(CFLAGS)
+LD = ld $(LDFLAGS)
+ASM = nasm $(ASMFLAGS)
all: build
build: $(TARGET)
-usrbin.bin: usrbin.s
- $(ASM) -f bin -o usrbin.bin usrbin.s
+.s.o:
+ $(ASM) -o $*.o $^
+
+.c.o:
+ $(CC) -c -o $*.o $^
-$(TARGET): usrbin.bin
- objcopy -I binary -O elf32-i386 -B i386 usrbin.bin usrbin.o
+$(TARGET): $(OBJS)
+ $(LD) -o usrbin.bin $(OBJS)
+ objcopy -I binary -O elf32-i386 -B i386 usrbin.bin $(TARGET)
clean:
rm -f usrbin.bin
+ rm -f $(OBJS)
rm -f $(TARGET)