Josh Coalson | bb7f6b9 | 2000-12-10 04:09:52 +0000 | [diff] [blame] | 1 | # |
| 2 | # GNU makefile fragment for building an executable |
| 3 | # |
| 4 | |
Josh Coalson | 955a767 | 2001-05-03 02:24:39 +0000 | [diff] [blame^] | 5 | CC = gcc |
| 6 | NASM = nasm |
Josh Coalson | bb7f6b9 | 2000-12-10 04:09:52 +0000 | [diff] [blame] | 7 | # LINKAGE can be forced to -static or -dynamic from invocation if desired, but it defaults to -static |
Josh Coalson | 955a767 | 2001-05-03 02:24:39 +0000 | [diff] [blame^] | 8 | LINKAGE = -static |
| 9 | LINK = gcc $(LINKAGE) |
| 10 | BINPATH = ../../obj/bin |
| 11 | LIBPATH = ../../obj/lib |
| 12 | PROGRAM = $(BINPATH)/$(PROGRAM_NAME) |
Josh Coalson | bb7f6b9 | 2000-12-10 04:09:52 +0000 | [diff] [blame] | 13 | |
| 14 | all : release |
| 15 | |
Josh Coalson | 9c03c19 | 2001-05-03 00:48:32 +0000 | [diff] [blame] | 16 | debug : CFLAGS = -g -O0 -DDEBUG $(DEBUG_CFLAGS) -Wall -W $(DEFINES) $(INCLUDES) |
| 17 | release : CFLAGS = -O3 -fomit-frame-pointer -funroll-loops -ffast-math -finline-functions -DNDEBUG $(RELEASE_CFLAGS) -Wall -W $(DEFINES) $(INCLUDES) |
Josh Coalson | bb7f6b9 | 2000-12-10 04:09:52 +0000 | [diff] [blame] | 18 | |
| 19 | LFLAGS = -L$(LIBPATH) |
| 20 | |
| 21 | debug : $(PROGRAM) |
| 22 | release : $(PROGRAM) |
| 23 | |
| 24 | $(PROGRAM) : $(OBJS) |
| 25 | $(LINK) -o $@ $(OBJS) $(LFLAGS) $(LIBS) |
| 26 | |
| 27 | %.o : %.c |
| 28 | $(CC) $(CFLAGS) -c $< -o $@ |
| 29 | %.i : %.c |
| 30 | $(CC) $(CFLAGS) -E $< -o $@ |
| 31 | |
Josh Coalson | 955a767 | 2001-05-03 02:24:39 +0000 | [diff] [blame^] | 32 | %.o : %.nasm |
| 33 | $(NASM) -f elf -d ELF -i i386/ $< -o $@ |
| 34 | |
Josh Coalson | bb7f6b9 | 2000-12-10 04:09:52 +0000 | [diff] [blame] | 35 | .PHONY : clean |
| 36 | clean : |
| 37 | -rm -f $(OBJS) $(PROGRAM) |
| 38 | |
| 39 | .PHONY : depend |
| 40 | depend: |
| 41 | makedepend -- $(CFLAGS) $(INCLUDES) -- *.c |