build: improve build efficiency

This commit is contained in:
iridiumR 2022-09-18 21:48:23 +08:00
parent 4a018bad5d
commit 72b7a424b7
No known key found for this signature in database
GPG key ID: 5574BE4450D55618
2 changed files with 29 additions and 16 deletions

3
.gitignore vendored
View file

@ -1,2 +1,5 @@
*.o *.o
*.ro
*.do
ddish
dish dish

View file

@ -1,22 +1,32 @@
OBJ=main.o line.o loop.o exec.o builtin.o SHELL := /bin/bash
CC=gcc CC = gcc
CFLAGS= -O3 -Wall SRC = main.c loop.c exec.c line.c builtin.c
OBJ = $(SRC:.c=.ro)
DBGOBJ = $(SRC:.c=.do)
EXE = dish
DBGEXE = ddish
all:release all:release debug
r:release debug: CFLAGS = -g -O0 -DDEBUG
release:dish release: CFLAGS = -Wall -O3
dish: $(OBJ) release: $(OBJ)
$(CC) $(CFLAGS) -o dish $(OBJ) $(CC) $(CFLAGS) -o $(EXE) $(OBJ)
d: debug: $(DBGOBJ)
make clean $(CC) $(CFLAGS) -o $(DBGEXE) $(DBGOBJ)
make debug
debug: CFLAGS += -DDEBUG -g
debug: dish
c: clean
clean: clean:
rm -f $(OBJ) dish rm -f *.o
$(OBJ):$(SRC)
$(CC) $(CFLAGS) -c $(SRC)
rename .o .ro *.o
$(DBGOBJ):$(SRC)
$(CC) $(CFLAGS) -c $(SRC)
rename .o .do *.o
c:clean
d:debug
r:release