Created
January 19, 2023 15:58
-
-
Save elPytel/1dbd6d9ecbd1aa0dcd6af1c6a8f19d46 to your computer and use it in GitHub Desktop.
Intermediate Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CC=clang | |
CFLAGS+= -Wall -Werror -std=gnu99 -g # -Werror -v -std=c99 | |
LFLAGS= -lm | |
CFLAGS+=$(shell sdl2-config --cflags) | |
LDFLAGS+=$(shell sdl2-config --libs) | |
NAME=my_app | |
APP=my_app | |
BINARIES=main | |
.PHONY: all clean run # ne-soubory ale proveditelne akce | |
# Kompilace | |
all: ${BINARIES} # prvni automaticky spousteny prikaz | |
OBJS=${patsubst %.c,%.o,${wildcard *.c}} | |
# Linkovani soboru | |
main: ${OBJS} | |
${CC} ${OBJS} ${LFLAGS} -o $(NAME) | |
${OBJS}: %.o: %.c | |
${CC} -c ${CFLAGS} $< -o $@ | |
# Generovani archivu | |
zip: | |
zip ${APP}.zip ${wildcard *.c} ${wildcard *.h} Makefile | |
# Konpilace & spusteni | |
run: all | |
./${NAME} | |
# Automaticke odstranovani souboru | |
clean: clean-bin clean-bck clean-zip # smaže binární soubor i zálohy | |
clean-zip: | |
rm -f $(APP).zip # smaze kompromovane soubory | |
clean-bin: | |
rm -f *.o $(NAME) # smaže binární soubory | |
clean-bck: | |
rm -f *~ *.bak # smaže všechny záložní soubory | |
# $< - automaticka promena <= z hlavičky pravidla | |
# $@ - automaticka promena <= z hlavičky pravidla | |
#$@ Obsahuje cíl, pro který se příkaz spouští. | |
#$^ Obsahuje všechny závislosti cíle. | |
#$< Obsahuje jméno první závislosti. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment