summaryrefslogtreecommitdiff
path: root/usrbin/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'usrbin/Makefile')
-rw-r--r--usrbin/Makefile32
1 files changed, 32 insertions, 0 deletions
diff --git a/usrbin/Makefile b/usrbin/Makefile
new file mode 100644
index 0000000..16a607f
--- /dev/null
+++ b/usrbin/Makefile
@@ -0,0 +1,32 @@
+TARGET = usrbin_blob.o
+
+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)
+
+.s.o:
+ $(ASM) -o $*.o $^
+
+.c.o:
+ $(CC) -c -o $*.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)