/[projet1]/public/rules.mk
Defence Force logotype

Contents of /public/rules.mk

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1206 - (show annotations)
Mon Sep 22 18:36:40 2014 UTC (5 years, 6 months ago) by Jylam
File size: 1949 byte(s)
GNU Make: Enable compilation with multiple .c files. Also add include guards on stdio.h and lib.h

1 # OSDK rules.mk for GNU Make
2 # Copyright (c) 2014 Jean-Yves Lamoureux <jylam@lnxscene.org>
3
4
5 # Path of the public/ directory (for instance /home/pennysbird/oric/public/)
6 # OSDKPATH = /home/user/osdkpath
7 CPP = cpp
8 CFLAGS += -Wall
9 TOOLS =$(OSDKPATH)/pc/tools/osdk/main/
10 AS =$(TOOLS)/xa/xa
11 CC =$(TOOLS)/compiler/compiler
12 LINKER =$(TOOLS)/link65/link65
13 MSPLIT =$(TOOLS)/macrosplitter/macrosplitter
14 BIN2TXT =$(TOOLS)/bin2txt/bin2txt
15 FILEPACK =$(TOOLS)/filepack/filepack
16 PICTCONV =$(TOOLS)/pictconv/pictconv
17 LINKLIB =$(TOOLS)/Osdk/_final_/lib/
18 OSDKINC =$(TOOLS)/Osdk/_final_/include/
19 MACROS =$(TOOLS)/Osdk/_final_/macro/MACROS.H
20 .PHONY: $(DATA) compile_c
21
22 ifndef OSDKPATH
23 $(warning **********************************************)
24 $(warning You must edit this file an fill OSDKPATH ***)
25 $(warning **********************************************)
26 $(error )
27 endif
28
29 RUNBEFOREHACK:=$(shell rm -f $(BIN).final.s $(BIN).final.c)
30 C_FILES=$(filter %.c, $(SRC))
31 %.o: %.s
32 cat $< >> $(BIN).final.s
33 %.o: %.c
34 cat $< >> $(BIN).final.c
35
36 $(BIN): $(DATA) $(OBJ) compile_c
37 ifneq ($(NO_LINK),1)
38 $(info LINKIIIIIING)
39 $(LINKER) -d $(LINKLIB) $(BIN).final.s -o .$(BIN).linked.s
40 else
41 cp $(BIN).final.s .$(BIN).linked.s
42 endif
43 $(AS) .$(BIN).linked.s -o $@.bin -bt 0x500 -C -W -v -l symbols.txt
44 $(TOOLS)/header/header -a1 $(BIN).bin $(BIN).tap 0x500
45 chmod +x $(BIN).tap
46
47 compile_c:
48 ifneq ($(strip $(C_FILES)),)
49 $(CPP) -traditional-cpp -I$(OSDKINC) $(BIN).final.c -o .1$(BIN).c
50 # Remove C comments
51 $(CPP) -xc++ .1$(BIN).c -o .2$(BIN).c
52 # Compile
53 $(CC) -O1 .2$(BIN).c .3$(BIN).c
54 # Apply macros
55 cpp -traditional-cpp -include $(MACROS) .3$(BIN).c -o .0$(BIN).s
56 cp .0$(BIN).s .1$(BIN).s
57 # Removes #'s
58 grep -v '^#' .1$(BIN).s > .2$(BIN).s
59 # Add \n after each assembly instruction
60 $(MSPLIT) .2$(BIN).s .3$(BIN).s
61 cat .3$(BIN).s >> $(BIN).final.s
62 else
63 endif
64 clean::
65 rm -f $(BIN) $(DATA) *.tap *.bin symbols.txt .*.c .*.s
66

  ViewVC Help
Powered by ViewVC 1.1.26