Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make: code refactoring #6

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
CROSS_COMPILE =
CFLAGS = -Os -Wall

CFLAGS = -Os -Wall -fsigned-char -g
LIBS = -ldl
BIN = amacc
SRC = $(BIN).c
QEMU = qemu-arm

ifeq ($(PREFIX), arm-linux-gnueabihf-)
CROSS_COMPILE = arm-linux-gnueabihf
else
CROSS_COMPILE = arm-linux-gnueabi
endif

CROSS_EXEC = $(QEMU) -L /usr/$(CROSS_COMPILE)

all: $(BIN)

amacc: amacc.c
$(CROSS_COMPILE)-gcc $(CFLAGS) -fsigned-char -o amacc amacc.c -g -ldl
$(CROSS_COMPILE)-gcc $(CFLAGS) -o $(BIN) $(SRC) $(LIBS)

check: $(BIN)
@echo "[ compiled ]"
@qemu-arm -L /usr/$(CROSS_COMPILE) ./amacc tests/hello.c
@$(CROSS_EXEC) ./$(BIN) tests/hello.c
@echo "[ nested ]"
@qemu-arm -L /usr/$(CROSS_COMPILE) ./amacc amacc.c tests/hello.c
@cloc --quiet amacc.c 2>/dev/null
@$(CROSS_EXEC) ./$(BIN) $(SRC) tests/hello.c
@cloc --quiet $(SRC) 2>/dev/null

clean:
$(RM) $(BIN)