write makefile, fix lzma_c build

This commit is contained in:
2025-03-22 22:44:24 +03:00
parent 244e5c92f8
commit a52875d507
4 changed files with 42 additions and 13 deletions

2
.gitignore vendored
View File

@@ -1,3 +1,5 @@
*.exe
*.o
kpack_c
*.code-workspace
*.bat

View File

@@ -1 +1,15 @@
# TODO
CFLAGS=-Wall -Wextra
LZMA_CFLAGS=-Wall -Wextra -O3
all: kpack_c
kpack_c: kpack_c.o LZMAEncoder.o MatchFinder.o RangeCoder.o
gcc -o kpack_c kpack_c.o LZMAEncoder.o MatchFinder.o RangeCoder.o
kpack_c.o: kpack_c.c
gcc -c $(CFLAGS) -o kpack_c.o kpack_c.c
LZMAEncoder.o: lzma_c/LZMAEncoder.c lzma_c/LZMAEncoder.h lzma_c/MatchFinder.h lzma_c/lzma.h lzma_c/RangeCoder.h lzma_c/RangeCoderBit.h lzma_c/RangeCoderBitTree.h lzma_c/common.h
gcc -c $(LZMA_CFLAGS) -o LZMAEncoder.o lzma_c/LZMAEncoder.c
MatchFinder.o: lzma_c/MatchFinder.c lzma_c/MatchFinder.h lzma_c/common.h
gcc -c $(LZMA_CFLAGS) -o MatchFinder.o lzma_c/MatchFinder.c
RangeCoder.o: lzma_c/RangeCoder.c lzma_c/RangeCoder.h lzma_c/RangeCoderBit.h lzma_c/RangeCoderBitTree.h lzma_c/lzma.h lzma_c/common.h
gcc -c $(LZMA_CFLAGS) -o RangeCoder.o lzma_c/RangeCoder.c
clean:
rm -f *.o *.exe kpack_c

6
kpack_c.c Normal file
View File

@@ -0,0 +1,6 @@
#include <stdio.h>
int main()
{
printf("Abobaa!");
}

View File

@@ -1,18 +1,25 @@
#ifndef _COMMON_H
#define _COMMON_H
typedef unsigned char byte;
typedef unsigned short word;
// conditional compiling, mike.dld
#ifdef WIN32
typedef unsigned __int64 uint64;
#else
typedef unsigned long long uint64;
#define __stdcall __attribute__((stdcall))
#endif
typedef byte bool;
#define true 1
#define false 0
#include <stdint.h>
#include <stdbool.h>
// typedef unsigned char byte;
// typedef unsigned short word;
// // conditional compiling, mike.dld
// #ifdef WIN32
// typedef unsigned __int64 uint64;
// #else
// typedef unsigned long long uint64;
// #define __stdcall __attribute__((stdcall))
// #endif
// typedef byte bool;
// #define true 1
// #define false 0
typedef uint8_t byte;
typedef uint16_t word;
typedef uint64_t uint64;
extern unsigned pack_length;
extern unsigned pack_pos;