53 lines
762 B
Bash
Executable file
53 lines
762 B
Bash
Executable file
#!/bin/sh
|
|
|
|
# get directory name
|
|
name="${PWD##*/}"
|
|
|
|
# create git repo
|
|
git init
|
|
|
|
# create gitignore
|
|
echo "\
|
|
bin/
|
|
$name
|
|
" >> .gitignore
|
|
|
|
# create source
|
|
mkdir -p src
|
|
|
|
# create main file
|
|
echo "\
|
|
int main(int argc, char **argv) {
|
|
return 0;
|
|
}
|
|
" > src/main.c
|
|
|
|
# create makefile
|
|
echo "\
|
|
CFLAGS += -Wall -Wextra -pedantic -std=c23
|
|
|
|
SDIR=src
|
|
ODIR=bin
|
|
BIN=$name
|
|
|
|
SRC=\$(shell find \$(SDIR) -type f -name '*.c')
|
|
SRH=\$(shell find \$(SDIR) -type f -name '*.h')
|
|
OBJ=\$(patsubst \$(SDIR)/%.c,\$(ODIR)/%.o,\$(SRC))
|
|
|
|
.PHONY: clean run
|
|
|
|
\$(BIN): \$(OBJ) \$(SRH)
|
|
@mkdir -p \$(ODIR)
|
|
\$(CC) -o \$@ \$(OBJ) \$(CFLAGS)
|
|
|
|
\$(ODIR)/%.o: \$(SDIR)/%.c \$(SRH)
|
|
@mkdir -p \$(ODIR)
|
|
\$(CC) -c -o \$@ $< \$(CFLAGS)
|
|
|
|
clean:
|
|
rm -rf \$(BIN) \$(ODIR)
|
|
|
|
run: \$(BIN)
|
|
./\$(BIN)
|
|
" > Makefile
|
|
|