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 *.exe
*.o
kpack_c kpack_c
*.code-workspace *.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 #ifndef _COMMON_H
#define _COMMON_H #define _COMMON_H
typedef unsigned char byte; #include <stdint.h>
typedef unsigned short word; #include <stdbool.h>
// conditional compiling, mike.dld
#ifdef WIN32 // typedef unsigned char byte;
typedef unsigned __int64 uint64; // typedef unsigned short word;
#else // // conditional compiling, mike.dld
typedef unsigned long long uint64; // #ifdef WIN32
#define __stdcall __attribute__((stdcall)) // typedef unsigned __int64 uint64;
#endif // #else
typedef byte bool; // typedef unsigned long long uint64;
#define true 1 // #define __stdcall __attribute__((stdcall))
#define false 0 // #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_length;
extern unsigned pack_pos; extern unsigned pack_pos;